//
//  ViewController.m
//  AdsBox
//
//  Created by Andy on 13-10-15.
//  Copyright (c) 2013年 Andy. All rights reserved.
//

#import "ViewController.h"
#import "AdsProvider.h"

#define TagAdsView 1024

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    adsList = [[NSMutableArray alloc] init];
    [AdsProvider shareProvider].rootVC = self;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50.f;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ads"];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ads"];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        UIView * adView = [[AdsProvider shareProvider] requestAdsViewAtIndex:indexPath.row];
        adView.frame = cell.contentView.frame;
        adView.tag = TagAdsView;
        [cell.contentView addSubview:adView];
    }
    return cell;
}
@end
